<?php

class Form_Abonne extends Zend_Form
{
	public function __construct($options = null)
	{
		parent::__construct($options);
		$this->setName('abonne');

		$decorators = array(
    'ViewHelper',
    'Errors',
		array('Description', array('tag' => 'p', 'class' => 'description')),
		array('HtmlTag', array('tag' => 'td')),
		array('Label', array('tag' => 'th')),
		array(array('tr' => 'HtmlTag'), array('tag' => 'tr'))
		);
		$decoratorsSubmit =array(
            'ViewHelper',
		array(array('td' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)),
		array(array('tr' => 'HtmlTag'), array('tag' => 'tr'))
		);
		
		
		$emailValidator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS);
		$emailValidator->setMessage('wrong.email');

		$id = new Zend_Form_Element_Hidden('id');

		$email = new Zend_Form_Element_Text('email');
		$email->setLabel('abonne_email')	
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty')	
		->addValidator($emailValidator)		
		->setDecorators($decorators);


		$pays = new  Zend_Form_Element_Select("pays");
		$pays->setLabel('Country')		
		->setDecorators($decorators)		
		->setRequired(true);
			
		$listePays = Zend_Locale::getTranslationList( 'territory', Zend_Registry::get ( 'Zend_Locale'),  null);
			
		$pays->addMultiOptions($listePays);
			
		$idNews = new Zend_Form_Element_Select('newsletter');
		$idNews->setLabel('abonne_newsletter')
		->setDecorators($decorators)
		->setRequired(true);

		$options = new Model_DbTable_Newsletters();
		$newsletters = $options->getAllNewsletter();
		$idNews->addMultiOptions($newsletters);


		$idActivation =  new Zend_Form_Element_Select('activation');
		$idActivation->setLabel('abonne_activation')
		->setDecorators($decorators)
		->setRequired(true);
		$activations= array('abonne'=>'abonne','desabonne'=>'desabonne');
		$idActivation->addMultiOptions($activations);

		//Une date
		$dateDesabonnement = new Zend_Dojo_Form_Element_DateTextBox('dateDesabonnement');
		$dateDesabonnement->setLabel('Date desabonnement');
		$dateDesabonnement->setDatePattern('yyyy-MM-dd');
		$decoratorDojo =array(
		'DijitElement',
		'Errors',
		array(array('data'=>'HtmlTag'),array('tag'=>'td')),
		array('Label',array('tag'=>'td')),
		array(array('row'=>'HtmlTag'),
		array('tag'=>'tr'))

		);
		$dateDesabonnement->setDecorators($decoratorDojo);
		 
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setAttrib('id', 'submitbutton');
		$submit->setDecorators($decoratorsSubmit);
		 
		
		
		
		
		$this->setDecorators(array('FormElements',array('HtmlTag', array('tag' => 'table')),'Form'));
        $this->addElements(array($id, $email,$pays,$idNews,$idActivation,$dateDesabonnement,$submit));

	}



	 
}